<template>
  <a-card :bordered="false">

    <!-- 左侧面板 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
            <a-form-item label="字典名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input autocomplete="off" placeholder="请输入字典名称" v-model="queryParam.dictName.value"></a-input>
            </a-form-item>
            <a-form-item label="字典编号" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input autocomplete="off" placeholder="请输入字典编号" v-model="queryParam.dictCode.value"></a-input>
            </a-form-item>
            <a-form-item>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" >重置</a-button>
              </span>
            </a-form-item>

      </a-form>
    </div>

      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="editDictItem(record)"><a-icon type="setting"/> 字典配置</a>
        </span>
      </a-table>

    <dict-modal ref="modalForm" @ok="modalFormOk"></dict-modal>  <!-- 字典类型 -->
    <dict-item-list ref="dictItemList"></dict-item-list>
  </a-card>
</template>

<script>
  // import { filterObj } from '../../utils/util';
  import AkfhListMixin from '../../mixin/AkfhListMixin'
  import DictModal from './modules/DictModal'
  import DictItemList from './DictItemList'
  import {sysDictUrl} from '../../api/url'
  import AFormItem from "ant-design-vue/es/form/FormItem";

  export default {
    name: "DictList",
    mixins:[AkfhListMixin],
    components: {AFormItem, DictModal, DictItemList},
    data() {
      return {
        description: '这是数据字典页面',
        ipagination:false,
        // 查询条件
        queryParam: {
          dictCode: {
            column:'dictCode',
            value:'',
            type:'eq'
          },
          dictName: {
            column:'dictName',
            value:'',
            type:'like'
          },
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 120,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '字典名称',
            align: "left",
            dataIndex: 'describe',
          },
          {
            title: '字典编号',
            align: "left",
            dataIndex: 'name',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {customRender: 'action'},
          }
        ],
        dict: "",
        url: sysDictUrl,
      }
    },
    methods: {

      //编辑字典数据
      editDictItem(record) {
        this.$refs.dictItemList.edit(record);
      },
      getQueryParams() {
       return {name:this.queryParam.dictCode.value, describe:this.queryParam.dictName.value};
      },
    },
  }
</script>
<style scoped>
  @import "../../assets/less/common.less";
</style>